//
//  YCAlertView.m
//  YCSchool
//
//  Created by gmall on 16/5/16.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCAlertView.h"

@interface YCAlertView()<UIAlertViewDelegate>
/** 代码块  */
@property (nonatomic, copy) YCAlertViewClickButtonAtIndexBlock block;
@end

@implementation YCAlertView

- (instancetype)initWithTitle:(NSString *)title message:(NSString *)msg cancelButtonTitle:(NSString *)cancelTitle otherButtonTitles:(NSArray *)otherButtonTitles clickButtonAtIndexBlock:(YCAlertViewClickButtonAtIndexBlock)clickButtonAtIndexBlock
{
    _block = clickButtonAtIndexBlock;
    if (self = [super initWithTitle:title message:msg delegate:self cancelButtonTitle:cancelTitle otherButtonTitles:nil]) {
        for (NSInteger i = 0; i< otherButtonTitles.count; i++) {
            [self addButtonWithTitle:otherButtonTitles[i]];
        }
    }
    return self;
}

// 展示提示
+ (void)showMsg:(NSString *)msg
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles: nil];
    [alertView show];
}

// 点击了哪一个
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    !_block?:_block(buttonIndex);
}


- (void)dealloc
{
    YCLogFunc;
}

@end
